package com.yhyvr.api.tool;

import com.lz.kit.LogKit;
import org.apache.commons.io.IOUtils;

import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.IOException;

/**
 * Created by zhangqin on 2017/4/12.
 */
public class GerReqBody {
    public static String getRequestBody(HttpServletRequest request) throws IOException {
        BufferedReader bufferedReader = request.getReader();
        StringBuilder stringBuilder = new StringBuilder(100);
        String readLine = "";
        try {
            while ((readLine = bufferedReader.readLine()) != null) {
                stringBuilder.append(readLine);
            }
        } catch (Exception e) {
            LogKit.error(e.getMessage(),e);
        } finally {
            IOUtils.closeQuietly(bufferedReader);
        }
        return stringBuilder.toString();
    }
}
